package day02;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// 单实例多线程
public class DemoServlet extends HttpServlet {
	private int count;
	
	public DemoServlet() {
		System.out.println("构造器");
	}
	
	// initialize
	@Override
	public void init() throws ServletException {
		System.out.println("servlet初始化");
	}
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 如果重写service方法，需要调用父类的service方法
		super.service(req, resp);
		
		System.out.println("service方法");
	}

	@Override	// instance/ object
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println(Thread.currentThread());

		// 如果重写doGet方法，不能调用父类的doGet
		System.out.println("doGet方法");
	}
	
	@Override
	public void destroy() {
		System.out.println("销毁方法");
	}
}
